<template>
	<n-input v-bind="getBindValues" />
</template>

<script lang="ts" setup>
import { inputProps, NInput } from 'naive-ui';
import setting from '@/setting/componentSetting';

const props = defineProps({
	...inputProps,
	maxlength: {
		type: Number,
		default: setting.input.maxlength,
	},
});

const getBindValues = computed(() => {
	const chageProps = {
		maxlength: props.maxlength,
		inputProps: props.inputProps,
	};
	if (props.type === 'textarea' && props.maxlength === setting.input.maxlength) {
		chageProps.maxlength = setting.input.textareaMaxlength;
	}
	if (props.type === 'password' && !props.inputProps) {
		chageProps.inputProps = {
			autocomplete: 'off',
		};
	}

	return {
		...unref(props),
		...chageProps,
	};
});
</script>

<style lang="scss" scoped></style>
